home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / FindChange.C < prev    next >
C/C++ Source or Header  |  1992-07-09  |  2KB  |  98 lines

  1. #ifdef __GNUG__
  2. #pragma implementation
  3. #endif
  4.  
  5. #include "FindChange_e.h"
  6.  
  7. #include "Class.h"
  8. #include "Application.h"
  9. #include "FindDialog.h"
  10. #include "ChangeDialog.h"
  11. #include "TextView.h"
  12. #include "MenuBar.h"
  13. #include "Menu.h"
  14.  
  15. static ChangeDialog *changeDialog= 0;
  16. static FindDialog *findDialog= 0;
  17.  
  18. ONEXIT(ChangeDialog)
  19. {
  20.     //SafeDelete(changeDialog);
  21.     //SafeDelete(findDialog);
  22. }
  23.  
  24. void FindChange::ShowFindDialog(TextView *tv)
  25. {
  26.     if (findDialog == 0) {
  27.     findDialog= new FindDialog("Find");
  28.     gApplication->AddManager(findDialog);
  29.     }
  30.     findDialog->SetTextView(tv);
  31.     findDialog->ShowOnWindow(tv->GetWindow());
  32. }
  33.  
  34. void FindChange::ShowChangeDialog(TextView *tv)
  35. {
  36.     if (changeDialog == 0) {
  37.     changeDialog= new ChangeDialog("Find/Change");
  38.     gApplication->AddManager(changeDialog);
  39.     }
  40.     changeDialog->SetTextView(tv);
  41.     changeDialog->ShowOnWindow(tv->GetWindow());
  42. }
  43.  
  44. void FindChange::FindAgain(TextView *tv)
  45. {
  46.     if (changeDialog != 0) {
  47.     changeDialog->SetTextView(tv);
  48.         changeDialog->FindAgain();
  49.     }
  50.     else if (findDialog != 0) {
  51.     findDialog->SetTextView(tv);
  52.         findDialog->FindAgain();
  53.     }
  54. }
  55.  
  56. void FindChange::DoSetupMenu(Menu *menu)
  57. {
  58.     char *pattern= "";
  59.     if (changeDialog != 0) 
  60.     pattern= changeDialog->GetSearchPattern();
  61.     else if (findDialog != 0)
  62.         pattern= findDialog->GetSearchPattern();
  63.     menu->EnableItem(cFINDAGAIN, strlen(pattern) != 0);
  64. }
  65.  
  66. void FindChange::InstallFind(MenuBar *mb, TextView *tv)
  67. {
  68.     Menu *m= mb->FindMenu(cEDITMENU);  
  69.     if (m) 
  70.     m->InsertItemsAfter(cLASTEDIT, "Find/Change...@F",  cFIND, 
  71.                                        "Find Again @G", cFINDAGAIN,
  72.                            0);
  73.     if (tv)
  74.     tv->SetFlag(eTextWantFindFocus);
  75. }
  76.  
  77. void FindChange::InstallChange(MenuBar *mb, TextView *tv)
  78. {
  79.     Menu *m= mb->FindMenu(cEDITMENU);  
  80.     if (m) 
  81.     m->InsertItemsAfter(cLASTEDIT, "Find/Change...@F",  cFIND, 
  82.                                        "Find Again @G", cFINDAGAIN,
  83.                            0);
  84.     if (tv)
  85.     tv->SetFlag(eTextWantFindFocus);
  86.  
  87. void FindChange::SetFocus(TextView *tv)
  88. {
  89.     if (tv->TestFlag(eTextWantFindFocus)) {
  90.     if (changeDialog != 0)
  91.         changeDialog->SetTextView(tv);
  92.     if (findDialog != 0)
  93.         findDialog->SetTextView(tv);
  94.     }
  95. }
  96.  
  97.